<?php
/**
 * @author kwor
 * @url http://www.kwor.cn
 *
 */
session_start();
require_once '../../../admin/data/mysql_config.php';
require_once '../../../admin/inc/lib/base/lib_common.php';

header("Content-Type:text/html;charset=".SN_CHARSET);

$action=$_REQUEST['action'];

/*************************验证表中同名信息（用户名，邮箱等）开始*****************************************/

/**
 *
 * 验证是否数据库中一存在相同信息
 * @param $table
 * @param $eqkey
 * @param $eqval
 */
function eqdata($table,$eqkey,$eqval) {
	$sql='select * from '.$table.' where '.$eqkey.'="'.$eqval.'"';
	$res=$GLOBALS[db]->getrow($sql);
	if($res){
		return true;
	}else {
		return false;
	}
}


//验证会员用户是否重复
if($action=='chkmembername'){
	$chkval=$_REQUEST['chkval'];
	if($chkval!==''){
		$res=eqdata('sn_members','name', $chkval);
		if($res==true)
		{
			echo 'true';
		}
	}else{
		echo 'true';
	}
}

//验证会员邮件是否重复
if($action=='chkmembermail'){
	$chkmail=$_REQUEST['chkmail'];
	if($chkmail!==''){
		$res=eqdata('sn_members','mail', $chkmail);
		if($res==true)
		{
			echo 'true';
		}
	}else{
		echo 'true';
	}
}

if($action=="subinfo"){
	$subemail=$_REQUEST['subemail'];
	$subcity=$_SESSION['city'];
	//echo $subemail;

	if($subemail!=="" && $subemail!==null){
		//echo $_REQUEST['subemail'];
		$sql="select * from sn_group_submail where mail = '".$subemail."'";
		$res=$db->getrow($sql);

		if($res['city']==$subcity){
			echo 'mail_has';
		}else{
			$sql="insert into sn_group_submail(mail,city) values('".$subemail."','".$subcity."')";
			$res=$db->query($sql);
			if($res){
				echo "mail_add";
			}else{
				echo "mail_unadd";
			}
		}
	}

	//*/
}


if($action=="submsginfo"){
	$subemail=$_REQUEST['subemail'];
	$subcity=$_SESSION['city'];
	//echo $subemail;

	if($subemail!=="" && $subemail!==null){
		//echo $_REQUEST['subemail'];
		$sql="select * from sn_group_submobile where mobile = '".$subemail."'";
		$res=$db->getrow($sql);

		if($res['city']==$subcity){
			echo 'mobile_has';
		}else{
			$sql="insert into sn_group_submobile(mobile,city) values('".$subemail."','".$subcity."')";
			$res=$db->query($sql);
			if($res){
				echo "mobile_add";
			}else{
				echo "mobile_unadd";
			}
		}
	}

	//*/
}

if($action=="subinfo1"){
	$subemail=$_REQUEST['subemail'];
	$subcity=get_cityid_byname($_REQUEST['subcity']);
	//$subcity=$_REQUEST['subcity'];
	if($subemail!=="" && $subemail!==null){
		//echo $_REQUEST['subemail'];
		$sql="select * from sn_group_submail where mail = '".$subemail."'";
		$res=$db->getrow($sql);
		if($res['city']==$subcity){
			echo 'mail_has';
			
		}else{
			$sql="insert into sn_group_submail(mail,city) values('".$subemail."','".$subcity."')";
			$res=$db->query($sql);
			if($res){
				echo "mail_add";
			}else{
				echo "mail_unadd";
			}
		}
	}

	//*/
}





/*************************验证表中同名信息（用户名，邮箱等）结束*****************************************/


?>